Register controlling apparatus and method capable of dynamic allocation of registers based on routines being processed

ABSTRACT

In a register controlling apparatus, whenever a routine is run, a register logicalal address, and the values of a local register pointer and a local register counter are selectively added, and thereby a register physical address and a new value of the local register pointer are outputted, resulting in the setting of the register available domain. Then, when the routine returns to a higher order routine, the set register available domain is released to be called by another subroutine, and further, when a register in another routine is accessed in an arbitrary routine, the register logical address is outputted as the register physical address to achieve the accessing, resulting in accomplishing an enhanced application efficiency of the register and an easy processing of a routine using many registers.

BACKGROUND OF THE INVENTION

[0001] 1. Field of the Invention

[0002] The present invention relates to a register controlling apparatus, and in particular, to an improved register controlling apparatus which is capable of processing a C programming language instructions efficiently and at a high speed in a central processing unit (hereinafter, called CPU) by controlling a plurality of registers.

[0003] 2. Description of the Prior Art

[0004] Conventionally, a register is a semiconductor memory device which is accessed by a CPU and employed in the writing and reading of data and various kinds of operations.

[0005] In the case of a reduced instruction set computer (RISC)-type CPU, there are provided tens of or hundreds of registers, and the construction of all the registers is divided into 2-16 banks.

[0006] As shown in FIG. 1, the conventional register controlling apparatus includes a CPU 1 for outputting a register address (Raddr) in accordance with a control data inputted through a data bus, and a memory 2 for writing data in a corresponding domain in accordance with the register address (Raddr) outputted from the CPU or reading the written data.

[0007] Here, the register addresses are sequential from the first to the last with consecutive numbers, and each address corresponds to a respective register.

[0008] Referring to the accompanying drawings, the operation of the conventional register controlling apparatus will now be described in detail.

[0009] First, when an arbitrary program routine is set by the user, the CPU 1 receives a control data through the data bus and then outputs a register address (Raddr). The memory 2 selects each corresponding address in accordance with the register address (Raddr) and runs the set routine.

[0010] Here, each register has a consecutive address, and when there are one hundred registers, the register address is put as Raddr0-Raddr99.

[0011] When the user enters a subroutine from an arbitrary program routine to run a more efficient high-level language such as a C programming language, he or she should know how to use a new routine in the subroutine.

[0012] Here, when the user is using n registers in an arbitrary routine and wants to call a subroutine to use m registers, to implement the subroutine, he or she should know which register he or she used in the high order routine and which register he or she can use in the present routine.

[0013] That is, when the user is using 11 registers (R0-R10) in the high order routine and wants to call a subroutine to use seven registers, he or she can use registers R11-R17.

[0014] The above-described operation would be programmed as follows: Routine A( )  { : declaring a high order routine integer R0 , R1 , R2 , . . . , R10 ; : arraying the registers used in the routine A . : the program text subroutine B( ) : calling a subroutine B . : the program text  } : terminating routine A Subroutine B( )  { : setting a subroutine B integer R11 , R12 , . . . , R17 : arraying the registers used in the routine B . : the program text  } : terminating subroutine B

[0015] That is, when allocating the programs as shown above, the subroutine B should know in advance that registers R0-R10 will be used in the routine A due to the characteristic that a register having a specific address is used only in a specific routine.

[0016] Therefore, when a register is to be used in each routine through some program, as shown in FIG. 3, the CPU 1 accesses a register allocated in each routine (A, B, C, . . . , N) in accordance with the flow of the program.

[0017] However, in the above-described procedure, it is very difficult to create a program because a register domain which each routine is to use should be set in advance when creating a program, and a register having a specific address has a low usage efficiency since the register having the specific address can use only the specific address.

[0018] Further, since the above-mentioned program is not proper for a high level language, especially for a C programming language, a low level language such as an assembly language should be disadvantageously used.

[0019] In addition, although to prevent the above-described problem, when compiling a program, a program managing a register (or a memory) is added, the size of the program is enlarged and the running speed is undesirably slowed down.

[0020]FIG. 2 is another embodiment of the conventional register controlling apparatus, wherein to solve the above-described problem, a higher performance RISC type CPU is substituted for the CPU 1 in FIG. 1, and the entire register range is divided into N register banks (4-1, 4-2, . . . , 4-n) to be used as the memory 2.

[0021] Here, the RISC type CPU 3 has tens of or hundreds of registers, that is, the entire register range is divided into 2-16 banks and each bank includes eight or sixteen registers.

[0022] This conventional register controlling apparatus will now be described in detail.

[0023] First, when the user runs a program and performs an arbitrary routine, the RISC type CPU 3 selects one register bank in a register stack divided into the N register banks 4-1, 4-2, . . . , 4-n, and then by using a register allocated in the selected register bank, the present routine is run.

[0024] And when the user calls a subroutine from the present routine which is a high order routine, the called subroutine automatically selects the next register bank in the register stack divided into the N register bank 4-1, 4-2, . . . , 4-n to run the program and then returns to the high order routine when the running of the program is done.

[0025] Here, when the subroutine returns to the high order routine, since the register bank which the subroutine selected and used is automatically released, the register bank can be reused when the subroutine is called from the high order routine next time.

[0026] That is, as shown in FIG. 4, when a subroutine B is called while using the register Bank0 4-1 in a high order routine A, the called subroutine B uses the next register Bank1 4-2, and then returns to the high order routine A and the selection of the register Bank1 4-2 is released.

[0027] Then, when a subroutine C is called from the high order routine A, the called subroutine C can also use the register Bank1 4-2 used in the subroutine B, and when a subroutine D is called from the subroutine C, the called subroutine D can use a next register Bank2 4-3.

[0028] When the selected register Bank2 4-3 returns to the high order routine C from the subroutine D, the selection of the register Bank2 4-3 is released. Therefore, when a subroutine E is called from the subroutine C, the called subroutine E can use the register Bank2 4-3 used in the previous subroutine C.

[0029] Therefore, in this conventional register controlling apparatus, when a subroutine is called from a high order routine to run a program and returns to the high order routine, since the register bank used in the previous subroutine can be used in another subroutine, the register controlling apparatus can have an improved application efficiency of the register, and is suitable for the processing of the program created in the C programming language.

[0030] However, in another embodiment of the conventional register controlling apparatus, since the entire register complement is divided into a predetermined number of register banks, registers are sometimes lacking or overabundant depending on the run routine, resulting in the undesirable lowering of the application efficiency of the register.

[0031] That is, when in a specific subroutine registers are used in such a small number as to leave remaing some unused registers, and in another subroutine, subroutines are called continuously enough to exceed the number of register banks, the registers remaining in servicing one routine can not used in servicing another register, resulting in the lacking of the registers.

[0032] In addition, when a parameter between each routine in a C programming language is set to be an address of an arbitrary variable, a variable of another routine is difficult to get access to from one routine.

SUMMARY OF THE INVENTION

[0033] Accordingly, it is an object of the present invention to provide an improved register controlling apparatus which is capable of setting the number of registers used by each routine suitably depending on each routine, and of processing the calling of subroutines until all the registers are used when each routine uses a small number of registers.

[0034] It is another object of the present invention to provide an improved register controller which is capable of setting an available register domain by selectively adding up the values of a register logical address and a local register pointer from CPU and the value of a local register counter and of performing the continuous calling of another subroutine from a higher order routine by releasing the set register available domain when a subroutine returns to a higher order routine.

[0035] To achieve the above object, there is provided an enhanced register controlling apparatus which includes a CPU for outputting the values of the register logical address, a first control signal and local register pointer, and the number (count value) of available registers, a register controller for selectively adding the values of a register logical address and a local register pointer, and the number (count value) of available registers and outputting a register physical address, and a memory for writing data in a domain set by the register physical address of the register controller or reading the written data.

[0036] To achieve another object of the present invention, there is provided a semiconductor apparatus in which a register controller controls the creation and access operation of a register physical address for the storing domain of a memory, wherein the register controller include a control circuit for outputting first and second control signals, respectively, in accordance with the control of a CPU, a local register pointer for setting a start address of register domains which will be used in a presently running program routine, a local register counter for setting the number of registers which will be used in the present/y running program routine, and an adder for adding the register logical addresses outputted from the CPU in accordance with the first control signal from the control circuit and the values of the local register pointer and then outputting a register physical address.

BRIEF DESCRIPTION OF THE DRAWINGS

[0037] The present invention will become more fully understood from the detailed description given hereinbelow and the accompanying drawings which are given by way of illustration only, and thus are not limitative of the present invention, and wherein:

[0038]FIG. 1 is a block diagram of a register controlling apparatus according to the conventional art;

[0039]FIG. 2 is a block diagram of another register controlling apparatus according to the conventional art;

[0040]FIG. 3 shows an example of the running order of a program and the setting of a register available domain in the apparatus of FIG. 1;

[0041]FIG. 4 shows an example in which a register bank is used according to the running order of the program according to the conventional art;

[0042]FIG. 5 is a block diagram of a register controlling apparatus according to the present invention;

[0043]FIG. 6 is a detailed block diagram of a register controller in FIG. 5;

[0044]FIG. 7 shows an example of a running order of a program in the inventive apparatus FIG. 5; and

[0045]FIGS. 8A through 8D are views showing examples of how a register available domain is set depending on the running of the program in FIG. 7.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0046] As shown in FIG. 5, a register controlling apparatus according to the present invention includes a CPU 10 for outputting register logical address (RL) values, a control signal (CS) and a local register pointer when a program routing is selected and the number (count value) of available registers, a register controller 20 for selectively adding the values of the register logical address and the local register pointer, and the number (count value) of available registers in accordance with the control signal (CS) from the CPU 10 and outputting a register physical address (RR), and a memory 30 for writing data in a domain set by the register physical address (RR) from the register controller 20 or reading the written data.

[0047] As shown in FIG. 6, the register controller 20 includes a control circuit 21 for outputting control signals (CTL1, CTL2) in accordance with the control signal (CS) from the CPU 10, a local register pointer 22 for receiving, storing and outputting the value of a local register pointer denoting a start address of a register domain from the CPU 10, a local register counter 23 for receiving, storing and outputting the number (count value) of the registers from the CPU 10, and an adder 24 for selectively adding up the number of the register logical addresses (RL), the start addresses of the register domain and the registers in accordance with the control signal CTL1 from the control circuit 21 and outputting a register physical address (RR).

[0048] The adder 24 outputs the register physical address (RR) corresponding to the register logical address (RL) in accordance with the control signal (CTL1) from the control circuit 21, or adds the values of the register logical address (RL) and the local register pointer 22 and then outputs the register physical address (RR), or adds the values of the local register pointer 22 and the local register counter 23 and outputs a new pointer value to the local register pointer 22.

[0049] The local register pointer 22 outputs the value of the pointer stored in accordance with the control signal (CTL2) or performs the inputting and outputting of data through the data bus.

[0050] The local register counter 23 outputs the number (count value) of the register stored in accordance with the control signal (CTL2) or performs the inputting and outputting of data through the data bus.

[0051] Referring to the accompanying drawings of the block diagrams, the register controlling apparatus according to the present invention will now be described.

[0052] Assume, for example, that the running order of the program set by the user will be performed as shown in FIG. 7.

[0053] First, when a routine A is run, the CPU outputs a register address from which the routine A starts and the number of registers available to the routine A to the data bus and stores them in the local register pointer 22 and the local register counter 23, respectively, as shown in FIG. 8A.

[0054] Here, the value of the local register pointer 22 is an arbitrary one, and the value of the local register counter 23 is determined when compiling a program.

[0055] For example, in creating a program, since the type and number of variables are declared, as shown in the following program routine written in the C programming language, these two factors are reflected when compiling the program. Routine A( )  { : declaring a routine name int R0 , R1 , . . . , Rn-1 : declaring the type and number of variables  . : the contents of the program } : finishing the routine

[0056] Accordingly, the adder 24 adds the values of the register logical address (RL) and the local register pointer 22 outputted from the CPU 10 and outputs the register physical address (RR), and thereby, a register domain which a routine will use in the memory 30 is determined and the registers are accessed in the determined register domain.

[0057] Then, when a subroutine B is called in the routine A, as shown in FIG. 8B, the values of the local register pointer 23 and the local register counter 23 in the routine A are outputted to the memory through the data bus in accordance with the control signal (CTL2) from the control circuit 21.

[0058] The local register pointer 22 and the local register counter 23 output the values of the pointer and the counter stored in accordance with the control signal (CTL2) to the adder 24, which adds the values of the local register pointer 22 and the local register counter 23 and outputs the added value as the register physical address (RR).

[0059] Then, the register physical address (RR) is stored again in the local register pointer 23, and sets a start address of a register domain which the routine B will use. The local register counter 24 receives and stores the number of registers which the routine B will use from the CPU 10 through the data bus in accordance with the control signal (CTL2), resulting in the decision of a register domain which the routine B uses.

[0060] Then, when in order to run the routine B the register logicalal address (RL) for setting a start address of the routine B is outputted from the CPU 10, the adder 24 receives the pointer value from the local register pointer 23, and adds the inputted pointer value and the register logical address (RL) and outputs the register physical address (RR), and thereby gets access to the corresponding registers of the memory 30.

[0061] And when the routine B is done and returns to the routine A, as shown in FIG. 8C, the values of the local register pointer 22 and the local register counter 23 in the routine A stored in the memory 30 are stored again in the local register pointer 22 and the local register counter 23 through the data bus, resulting in the continued running of routine A in the program.

[0062] Here, when the program returns to the routine A from routine B, the register domain set for routine B is released.

[0063] Then, when a subroutine C is called in the routine A, the same operation as when the subroutine B was called in the routine A is repeated, and the register domain which the routine C will use is determined.

[0064] When a subroutine D is called in the routine C, as shown in FIG. 8D, a register available domain for the routine D is decided next to the register available domain for the routine C.

[0065] Meanwhile, when the CPU 10 outputs the control signal (CS) and the register logical address (RL) in order to get access to a register domain of another routine from an arbitrary routine, the adder 24 outputs the register logical address (RL) inputted from the CPU 10 in accordance with the control signal (CTL1) from the control circuit 21 as the register physical address (RR), and thereby the memory 30 performs the inputting and outputting of data in a domain set by the register physical address (RR) outputted from the register controller 20.

[0066] As described in detail above, according to the present invention, the number of the registers used in a specific routine is set suitably for each routine, and even when each routine uses a small number of registers, since the callings of the subroutines can be processed until all the registers are all used, an improved application efficiency of the registers can be achieved.

[0067] Further, according to the present invention, since the limit of the number of the registers usable in one routine is the total number of the entire registers, a routine which uses many registers can be easily processed.

[0068] Therefore, an easier creation of a program and a faster processing speed can be realized, and especially such a high level language as a C programming language can be processed with less effort.

[0069] Although the preferred embodiments of the present invention have been disclosed for illustrative purposes, those skilled in the art will appreciate that various modifications, additions and substitutions are possible, without departing from the scope and spirit of the invention as recited in the accompanying claims. 

What is claimed is:
 1. A register controlling apparatus, comprising: A CPU for outputting values of a register logical address, a first control signal and a local register pointer when a program routine is selected and a count value of available registers; a register controller for selectively adding the values of the register logical address and the local register pointer, and the count value of available registers in accordance with the first control signal from the CPU and outputting a register physical address; and a memory for writing data in a domain set by the register physical address of the register controller or reading the written data.
 2. The apparatus of claim 1 , wherein the register controller comprises a control circuit for outputting second and third control signals in accordance with the first control signal from the CPU; a local register pointer for receiving and storing the value of the local register pointer representing a start address of a register domain from the CPU and outputting the value in accordance with the third control signal; a local register counter for receiving and storing the count value of the registers from the CPU and outputting the count value in accordance with the third control signal; and an adder for selectively adding the register logical addresses, the values of the local register pointer and the local register counter from the CPU in accordance with the first control signal from the control circuit and then outputting the register physical address and a new value of the local register pointer.
 3. The apparatus of claim 2 , wherein the adder selectively adds the value of the local register counter to the register logical address from the CPU and then outputs the register physical address when an arbitrary subroutine is called in a presently executing program routine.
 4. The apparatus of claim 2 , wherein the adder outputs the register logical address as the register physical address in accordance with the second control signal when a register domain in another routine is accessed during an arbitrary routine.
 5. The apparatus of claim 2 , wherein the local register pointer stores the added value outputted from the adder as a start address of an available domain of a called subroutine when another subroutine is called in the presently executing program routine.
 6. The apparatus of claim 5 , wherein the available domain of the subroutine is set next to the available domain of the higher order routine whenever the domain is called.
 7. The apparatus of claim 2 , wherein the local register counter stores the number of the registers which a corresponding routine will use from the CPU whenever a subroutine is called in a presently executing program routine.
 8. The apparatus of claim 1 , wherein the memory stores the values of the local register pointer and the local register counter of a higher order routine when a subroutine is called in a presently running higher order routine.
 9. The apparatus of claim 2 , wherein the local register pointer and the local register counter receive and store the values of the local register pointer and the local register counter for a higher order routine stored in the memory to perform the continuous running of the returning higher oreder routine, when they return from a subroutine to the higher order routine.
 10. The apparatus of claim 9 , wherein the register domain set for the subroutine is released when the subroutine returns to the higher order routine.
 11. In a semiconductor apparatus in which a register controller controls the creation and access operation of a register physical address for the storing domain of a memory, a register controller comprising: a control circuit for outputting first and second control signals, respectively, in accordance with the control of a CPU; a local register pointer for setting a start address of register domains which will be used by a presently running program routine; a local register counter for setting a number of registers which will be used by a presently running program routine; and an adder for adding a register logical addresses outputted from the CPU in accordance with the first control signal from the control circuit and the values of the local register pointer and then outputting a register physical address. 